<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html>
<c:set value="${pageContext.request.contextPath }" var="cPath" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

<c:if test="${!empty msg }">
alert("${msg }");
</c:if>

  function codeAddress() {
   var geocoder = new google.maps.Geocoder();
   
    var address = document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
    	
      if (status == google.maps.GeocoderStatus.OK) {
        document.getElementById("lat").value = results[0].geometry.location.lat();
        document.getElementById("lng").value = results[0].geometry.location.lng();
        alert("주소 등록이 되었습니다^^");
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }
  
  function validate_check() {
  	if(document.budForm.sh_name.value == "") {
  		alert('벗집이름을 입력하세요.');
  		document.budForm.sh_name.focus();
  	} else if(document.budForm.sh_pass.value == "") {
  		alert('비밀번호를 입력하세요.');
  		document.budForm.sh_pass.focus();
  	} else if(document.budForm.sh_phone.value == "") {
  		alert('전화번호를 입력하세요.');
  		document.budForm.sh_phone.focus();
  	} else if(document.budForm.sh_add.value == "") {
  		alert('주소를 입력하세요.');
  		document.budForm.sh_add.focus();
  	} else if(document.budForm.sh_message.value == "") {
  		alert('메세지를 입력하세요.');
  		document.budForm.sh_message.focus();
  	} else if(document.budForm.sh_photo.value == "") {
  		alert('사진을 입력하세요.');
  		document.budForm.sh_photo.focus();
  	} else {
  		document.budForm.submit();
  	}
  }
</script>
</head>
<body>
<div align="center" id="boardForm3">
<form action="${cPath }/shopInsert.do" 
	method="post" enctype="multipart/form-data" name="budForm">
<div id="imgt3">
	<img src="${cPath }/css/b1.png" width="35%" align="left"><br>
	<br><br><br><br><br>
	</div>
<table>
	<tr>
		<th width="50%">벗집이름</th>
		<td>
			<INPUT type="text" id="text" name="sh_name"/>
		</td>
	</tr>
	<tr>
		<th width="50%">벗집비밀번호</th>
		<td>
			<INPUT type="password" id="text" name="sh_pass"/>
		</td>
	</tr>
	<tr>
		<th width="50%">벗집전화번호</th>
		<td>
			<INPUT type="text" id="text" name="sh_phone"/>
		</td>
	</tr>
	<tr>
		<th width="50%" >벗집주소</th>
		<td id="left2">
			<INPUT type="text" name="sh_add" id="address"/>
			<input type="button" value="주소등록" onclick="codeAddress()"/>
		</td>
	</tr>
	<tr>
		<th width="50%">벗집메세지</th>
		<td>
			<input type="text" id="text" name="sh_message"/>
		</td>
	</tr>
	<tr>
		<th width="50%">벗집사진</th>
		<td>
			<input type="file" id="text" name="sh_photo"/>
		</td>
	</tr>
	
	
</table>
<input id="lat" type="hidden" name="sh_latitude">
<input id="lng" type="hidden" name="sh_longitude">
<br>
			<input type="button" value="등록하기" onclick="validate_check();"/>
</form>
</div>
</body>
</html>